package org.flowable.pz.entity.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class FlowableResultDto<T> implements Serializable {
    private String message;
    private T data;
    private int code;

    public static FlowableResultDto<Void> success(){
        return new FlowableResultDto<>("操作成功", null, 200);
    }

    public static FlowableResultDto<Void> successMsg(String message){
        return new FlowableResultDto<>(message, null, 200);
    }

    public static <T> FlowableResultDto<T> success(T data){
        return new FlowableResultDto<>("操作成功", data, 200);
    }

    public static <T> FlowableResultDto<T> success(T data, String message){
        return new FlowableResultDto<>(message, data, 200);
    }

    public static <T> FlowableResultDto<T> error(){
        return new FlowableResultDto<>("操作失败", null, 500);
    }

    public static <T> FlowableResultDto<T> error(String message){
        return new FlowableResultDto<>(message, null, 500);
    }
}
